package src.main.StructuralPatterns.Adapter;

import src.main.StructuralPatterns.Adapter.Class.DatabaseAdapter;
import src.main.StructuralPatterns.Adapter.Class.NewDatabase;
import src.main.StructuralPatterns.Adapter.Default.GameEventListener;
import src.main.StructuralPatterns.Adapter.Default.GamepadEventAdapter;
import src.main.StructuralPatterns.Adapter.Default.KeyboardEventAdapter;
import src.main.StructuralPatterns.Adapter.Object.AC;
import src.main.StructuralPatterns.Adapter.Object.DC;
import src.main.StructuralPatterns.Adapter.Object.PowerAdapter;

public class Client {
    public static void main(String[] args) {
        // 对象适配器模式
        AC ac = new AC();
        System.out.println("原输出电压:" + ac.outputAC() + "V");
        DC charger = new PowerAdapter(ac);
        System.out.println("输出电压:" + charger.outputDC() + "V");

        // 类适配器
        NewDatabase db = new DatabaseAdapter();
        db.connect("jdbc:mysql://localhost:3306");
        db.execute("SELECT * FROM Users");

        // 缺省适配器
        // 键盘监听器
        GameEventListener keyboardListener = new KeyboardEventAdapter();
        keyboardListener.onKeyPress(65);    // 输出：按键按下: 65
        keyboardListener.onMouseClick(1);    // 无输出（空实现）

        // 手柄监听器
        GameEventListener gamepadListener = new GamepadEventAdapter();
        gamepadListener.onGamepadConnected(); // 输出：手柄已连接
        gamepadListener.onKeyPress(0);        // 无输出（空实现）
    }
}
